<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in" ref="dialogBox">
      <div class="cornerComment-in-title">
        <!--        type 0 学生 2 职工-->
        <span>{{ typeQuestion == 1 ? '已' : '未' }}反馈人员</span>
        <span class="el-icon-circle-close close-Btn-line" @click="closePOpup"></span>
      </div>
      <div class="commentBody">
        <!--本体列表，数据 -->
        <div class="table-body">
          <div class="table-body-box">
            <el-table
                ref="multipleTable"
                :data="arryList"
                :stripe="tableStyle.tableStripe"
                :border="tableStyle.tableBorder"
                tooltip-effect="dark"
                style="width: 100%"
                :height="tableHeight"
                header-cell-class-name="table-text-c"
                cell-class-name="table-text-c">
              <el-table-column
                  label="姓名"
                  prop="name">
                <template slot-scope="scope">
                  <span v-if="typeQuestion==1">{{ scope.row.user.realname }}</span>
                  <span v-else>{{ scope.row.realname }}</span>
                </template>
              </el-table-column>
              <el-table-column
                  label="班级">
                <template slot-scope="scope">
                  <span
                      v-if="typeQuestion==1">{{ scope.row.user.classes ? scope.row.user.classes.section_id : '' }}-{{ scope.row.user.classes ? scope.row.user.classes.class_name : '' }}</span>
                  <span
                      v-else>{{ scope.row.classes ? scope.row.classes.section_id : '' }}-{{ scope.row.classes ? scope.row.classes.class_name : '' }}</span>
                </template>
              </el-table-column>
              <el-table-column
                  label="签名" v-if="typeQuestion == 1">
                <template slot-scope="scope">
                  <viewerModle type="1" :imgSrc="scope.row.pic" widthNumber="small" v-if="scope.row.pic"></viewerModle>
                </template>
              </el-table-column>

              <el-table-column
                  label="状态">
                <template slot-scope="scope">
                  <span v-if="typeQuestion==1" class="c-success">已反馈</span>
                  <span v-else class="c-danger">未反馈</span>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
        <!--工具条 分页-->
        <el-col :span="24" class="toolbar">
          <el-pagination
              background
              :page-size="page.pagesize"
              :current-page="page.pageindex"
              layout="total, prev, pager, next"
              :total="page.total"
              @current-change="handleSizeChange"></el-pagination>
        </el-col>
      </div>
      <div class="cornerComment-in-footer">
        <el-button @click="closePOpup" size="small">确定</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import {pagination, yearDay, tableoption} from '@/utils/util.js'

export default {
  props: ['visible', 'typeQuestion', 'detailId'], // commoent 学生点评 collection 学生采集
  components: {},
  data() {
    return {
      tableStyle: tableoption,
      dialogVisible: false,
      arryList: [], // 数据列表
      // 页数
      page: {
        pageindex: pagination.pageIndex,
        pagesize: pagination.pageSize,
        total: pagination.total
      },
      tableHeight: 0,
    }
  },
  watch: {
    visible() {
      let n =this;
      if (this.visible) {
        this.$nextTick(() => {
          let height = n.$refs.dialogBox.offsetHeight;  //top 50 1 search 50 page 50 10 footer 50 1
          n.tableHeight = height - (51 + 20 +50+ 51)
        })
        this.InitFn()
      } else {
        this.page.pageindex=1
        this.arryList = [];
      }
      this.dialogVisible = this.visible
    }
  },
  created() {
  },
  methods: {
    // 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    },
    getJson(option) {
      return JSON.parse(JSON.stringify(option))
    },
    // 初始化
    async InitFn() {
      let src_ = this.api.questionnaire_inside_user // 已反馈
      if (Number(this.typeQuestion) === 2) {
        src_ = this.api.questionnaire_inside_unread
      }
      this.$fetch(src_, {
        id: this.detailId,
        p: this.page.pageindex
      }).then((response) => {
        if (response.code === 0) {
          this.arryList = response.list.data
          this.page.total = response.list.total
        } else {
        }
      }).catch((err) => {
        console.log(err)
      })
    },
    // 分页
    handleSizeChange(val) {
      this.page.pageindex = val
      this.InitFn()
    },
    clearWord() {
      let getPower = this.getJson(this.getPower)
      getPower.section_id.valueText = ''
      getPower.section_id.child[0].valueText = ''
      this.getPower = this.getJson(getPower)
      this.value1 = []
      this.healthname = ''
      this.searWord.start_time = ''
      this.searWord.end_time = ''
      if (Number(this.type) === 1) {
        this.searWord.realname = ''
      } else {
        this.searWord.name = ''
      }
      this.searWord.is_green = ''
      this.searWord.is_other_green = ''
      this.searWord.is_temperature = ''
    },
    addActive(id) {
      this.healthId = id;
      this.healthdetailvisible = true;
      // this.$router.push('/healthEdit?id=' + id)
    },
    // 更新值
    updateVal(option) {
      // console.log('变更数据收到的数据内容：', option)
      if (option.input) {
        this.searWord[option['input'].name] = option['input'].valueText
      } else if (option.select) {
        for (let i in option.select) {
          if (option.select[i].name) {
            this.searWord[option.select[i].name] = option.select[i].valueText
          } else {
            this.searWord[option.select[i - 1].name] = option.select[i].valueText ? option.select[i].valueText : option.select[i - 1].valueText
          }
        }
      }
    },
  },
  mounted() {
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 90%;
  height: 80%;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 10px 20px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}
</style>


